﻿#pragma once
#include "PowerFlow_MoInterface.h"
#include "../ModelObj/FindLinkWireTool.h"

class CFindLinkWireTool;

class POWERFLOW_MO CBigDrawing2MoAnimation :
	public CPowerFlow_MoInterface
{
public:
	CBigDrawing2MoAnimation(void);
	~CBigDrawing2MoAnimation(void);

	virtual void OutputDynamicComponentInfo( HBaseView* pHView );
	
	virtual CString GetActiveLayerMoParams(HBaseView* pHView);
	//sParamsDataֵΪname,type,value,name,type,value,....;
	virtual void UpdatePowerFlowMoParamsValue(HBaseView* pHView,CString sParamsData/*,int nPositive*/); 
	virtual bool DisplayPowerFlowAnimation( HBaseView* pHView );
	virtual bool IsDeviceCloseSwitch(HBaseView* pHView,CDeviceDisplayObj* pDevDis);
	virtual bool StopPowerFlowAnimation( HBaseView* pHView );

	virtual CLayer* GetAnimationFlowLayer(HBaseView* pHView);

protected:
	CString GetDevicePowerLossVarName( CDevice* pDev );
	bool DisplayPowerLayerAnimation( HBaseView* pHView );
	void DisplayAllSchBusAnimation( HBaseView* pHView );
	void CreateAndHideTrackerForSchBus( CSchematicBusDisplayObj* pSchBusDisObj ,HBaseView* pHView);
	void GetWireDisObjVoltage(CWireDisplayObj* pWireDisObj,double &dSt,double &dEnd);
	void GetWireDisObjCurrent(CWireDisplayObj* pWireDisObj,double &dSt,double &dEnd);
	void GetWireDisObjMergerdPins(CWireDisplayObj* pWireDisObj,vector<CPin* > &vecStPins,vector<CPin* > &vecEndPins);
	CString GetPinCurrentVarName(CPin* pPin);
	CString GetPinVoltageVarName(CPin* pPin);
	double GetPinCurrentValue(CPin* pPin);
	double GetPinVoltageValue(CPin* pPin);
private:
	void GetPositiveShowedWireDisObj(CSystem* pBigDrawing,CLayer* pLayer);
	bool ResetSchConAndWireText( CWireDisplayObj* pWireDisObj,double dStValue,double dEndValue);
	bool IsPowerReturnWire(CWire* pWire);
	bool IsPowerMainWire(CWire* pWire);
	ePowerTrackerShowType GetDirection(double dStCurrent,double dEndCurrent);
	ePowerTrackerShowType GetDirection_BelongProxyDeviceOrSepConn(double dStCurrent,bool bConfigPinSt);
	bool GetWireDisObjVoltage_BelongProxyDeviceOrSepConn(CWireDisplayObj* pWireDisObj,double &dSt,double &dEnd);
	bool GetWireDisObjCurrent_BelongProxyDeviceOrSepConn(CWireDisplayObj* pWireDisObj,double &dSt,double &dEnd,bool &bConfigPinSt);
protected:
	list<CWireDisplayObj*> m_lstPositiveWireDis;  //正线集合；要保存，否则每次更新设置值时都要获取，太慢;
	map<CDevice*,list<CWireDisplayObj*>> m_mapDev2PositiveWires;
	map<CWireDisplayObj*,pair<vector<CPin*>,vector<CPin*> > > m_mapWire2MergePins;
	map<string,double> m_mapVarValue;
	map<CPin*,CString> m_mapPin2VarID; //管脚2Mo中的变量id;

	CFindLinkWireTool m_linkWireTool;

	bool m_bPostData;
};

